﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Marmat.Common.Http
{
    /// <summary>
    /// 基于http实现Result结构的命令工厂。
    /// </summary>
    public class HttpResultCommandFactory : ICommandFactory
    {
        /// <summary>
        /// 获取接口对应的服务实例。
        /// </summary>
        /// <typeparam name="TInterface">接口类型</typeparam>
        /// <returns></returns>
        public TInterface GetService<TInterface>() where TInterface : class
        {
            Castle.DynamicProxy.ProxyGenerator generator = new Castle.DynamicProxy.ProxyGenerator();
            TInterface result = generator.CreateInterfaceProxyWithoutTarget<TInterface>(new HttpResultCommandFactoryInterceptor());
            return result;
        }
    }
}
